<?php
// +----------------------------------------------------------------------

namespace app\mall\model;

use think\Model as ThinkModel;
use util\Tree;
use think\facade\Db;

/**
 * 商品模型
 * @package app\cms\model
 */
class Cart extends ThinkModel
{
    // 设置当前模型对应的完整数据表名称
    protected $name = 'mall_cart';

    // 自动写入时间戳
    protected $autoWriteTimestamp = true;

    /**
     * 获取商品列表
     * @return array|mixed
     */
    public static function getList($map = [], $order = [])
    {
        $data_list = self::view('mall_cart', true)
            ->view("mall_goods", ['title','price','logo'], 'mall_goods.id=mall_cart.gid', 'left')
            ->where($map)
            ->order($order)
            ->paginate(config('paginate'));
		// foreach($data_list as $key=>$value){
		// 	self::update(['id'=>$value['id'], 'pack_share' => $value['pro_share']]);
		// }
        return $data_list;
    }
    /**
     * 获取购物车列表
     * @return array|mixed
     */
    public static function getAll($map = [], $order = [])
    {
        $data_list = self::view('mall_cart', 'id,gid,number,pay_price')
            ->view("mall_goods", ['title','price','price_pifa','price_xian','price_qu','agent','price_shi','price_sheng','er_price_xian','er_price_qu','er_price_shi','er_price_sheng','san_price_xian','san_price_qu','san_price_shi','san_price_sheng','logo'], 'mall_goods.id=mall_cart.gid', 'left')
            ->where($map)
            ->order($order)
            ->select();
        return $data_list;
    }
	/**
	 * 获取IDS
	 * @param string $id 文档id
	 * @return array
	 */
	public static function getids()
	{
	    return self::where('status', 1)->column('id');
	}
    
}
